//
//  RTComposeButton.swift
//  Weibo
//
//  Created by Brisinga on 16/3/11.
//  Copyright © 2016年 Root. All rights reserved.
//

import UIKit

class RTComposeButton: UIButton {
    
    
    var menInfo: RTComposeModel? {
    
        didSet {
        
            setImage(UIImage(named: menInfo!.icon!), forState: UIControlState.Normal)
            
            setTitle(menInfo!.title, forState: UIControlState.Normal)
        }
    }
    
    
    
    // 初始化
    override init(frame: CGRect) {
        
        super.init(frame: frame)
        
        setupUI()
    }
    
    
    // 重写高亮状态
    override var highlighted: Bool {
        
        get {
        
            return false
        }
        
        set {
        
        
        }
    
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    // 初始化控件
    private func setupUI() {
    
        titleLabel?.font = UIFont.systemFontOfSize(16)
        titleLabel?.textAlignment = .Center
        setTitleColor(UIColor.darkGrayColor(), forState: UIControlState.Normal)
        
        imageView?.contentMode = .Center
    }
    
    
    
    // 布局控件
    override func layoutSubviews() {
        
        super.layoutSubviews()
        
        let width = self.frame.size.width
        let height = self.frame.size.height
        
        imageView?.frame = CGRectMake(0, 0, width, width)
        
        titleLabel?.frame = CGRectMake(0, width, width, height-width)
    }

}
